<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>组件中插槽的使用</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/3.0.2/vue.global.js"></script>
</head>

<body>
    <div id="app">

        <!-- const app = Vue.createApp({
            template: ` 
                        <h2>唯爱薇朝圣之路</h2>
                        <Courses> DevOps课程 </Courses>            
                    `
        })
    
        app.component('Courses', {
            template: `
                <div>
                    <span>你选择了如下课程</span>
                    <span>
                        <slot></slot>
                    </span>
                </div>
            `
        })
    
        const vm = app.mount("#app") -->


    </div>
</body>
<script>
    const app = Vue.createApp({
        data() {
            return {
                coursesInfo: {
                    "devops" : "开发运维课程",
                    "golang" : "Golang语言课",
                    "python" : "Python语言课",
                },
            }
        },
        template: ` 
                    <h2>唯爱薇朝圣之路</h2>
                    <hr \>
                    <Courses style="color:red;font-size:25px;" :coursesInfo="coursesInfo"> DevOps课程  {{ devops }} </Courses>
                    <hr \>
                    <Courses style="color:green;font-size:25px;" :coursesInfo="coursesInfo"> Golang课程 {{ golang }}</Courses>
                    <hr \>
                    <Courses style="color:red;font-size:25px;" :coursesInfo="coursesInfo"> Python课程 {{ python }}</Courses>
                    <hr \>
                    <Courses style="color:green;font-size:16px;" :coursesInfo="coursesInfo"></Courses>            
                `
    })

    app.component('Courses', {
        props: ['coursesInfo'],
        template: `
            <div>
                <span>你选择了如下课程  {{ coursesInfo.devops }}、{{ coursesInfo.golang }}、{{ coursesInfo.python }} 中的 ： </span>
                <span>
                    <slot>如果不传课程，你就看这个默认课程吧《唯爱薇o朝圣之路.技术心理学》</slot>
                </span>
                <p>
                    <CourseInfo />
                </p>
            </div>
        `
    })
    app.component('CourseInfo', {
        template: `
            <div>
                <span>课程简介如下.....</span>
            </div>
        `
    })    

    const vm = app.mount("#app")
</script>

</html>